﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true"
    CodeBehind="QL_User.aspx.cs" Inherits="ChineseSchool.Admin.QL_User" ValidateRequest="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .form-horizontal .control-label
        {
            text-align: left;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            var txtUserName = $('#<%=txtUserName.ClientID %>');
            $("#<%=btnAdd.ClientID %>").click(function () {
                if (txtUserName.val().length <= 0) {
                    txtUserName.css("border", "1px solid red");
                    return false;
                }
                else {
                    return confirm('Bạn có muốn thêm mới không?');
                }
            });
            $("#<%=btnEdit.ClientID %>").click(function () {
                if (txtUserName.val().length <= 0) {
                    txtUserName.css("border", "1px solid red");
                    return false;
                }
                else {
                    return confirm('Bạn có muốn sửa thông tin?');
                }
            });

            $('#<%= imgAvatar.ClientID%>').css("vertical-align", "bottom");

            $('#btnChangePassword').click(function () {
                $('.modal').modal('show');
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder_Top" runat="server">
    <div class="example-modal">
        <div class="modal">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">Chọn thay đổi ảnh đại diện</h4>
                    </div>
                    <div class="modal-body">
                        <asp:FileUpload ID="uploadAvatar" runat="server" />
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Đóng</button>
                        <asp:Button ID="btnSelectImage" CssClass="btn btn-primary" Text="Chọn ảnh này!" OnClick="BtnSelectImageClick" runat="server" />
                    </div>
                </div>
            </div>
        </div>
    </div>
    <asp:Panel ID="panAdd" runat="server" Visible="false">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-info">
                    <div class="box-header with-border">
                        <asp:Label ID="lblTitle" runat="server"></asp:Label>
                    </div>
                    <div class="form-horizontal">
                        <div class="box-body">
                            <div class="form-group">
                                <asp:Label ID="lblUserName" Text="Tên đăng nhập:" CssClass="col-sm-2 control-label" runat="server" />
                                <div class="col-sm-10">
                                    <asp:TextBox runat="server" ID="txtUserName" Text='<%# Bind("UserName") %>' MaxLength="150"
                                        CssClass="form-control"></asp:TextBox>
                                </div>
                            </div>
                            <div class="form-group">
                                <asp:Label ID="Label2" Text="Họ và tên:" CssClass="col-sm-2 control-label" runat="server" />
                                <div class="col-sm-10">
                                    <asp:TextBox runat="server" ID="txtFullName" Text='<%# Bind("FullName") %>' MaxLength="150"
                                        CssClass="form-control" HtmlEncode="False"></asp:TextBox>
                                </div>
                            </div>
                            <div class="form-group">
                                <asp:Label ID="lblAvatar" Text="Ảnh đại diện:" CssClass="col-sm-2 control-label" runat="server" />
                                <div class="col-sm-10">
                                    <asp:Image ID="imgAvatar" Width="128" Height="128" runat="server" />
                                    <a href="#" id="btnChangePassword">Đổi ảnh đại diện</a>
                                </div>
                            </div>
                            <div class="form-group">
                                <asp:Label ID="lblEmailData" Text="Địa chỉ email:" CssClass="col-sm-2 control-label" runat="server" />
                                <div class="col-sm-10">
                                    <asp:TextBox runat="server" ID="txtEmail" Text='<%# Bind("Email") %>' MaxLength="150"
                                        CssClass="form-control"></asp:TextBox>
                                </div>
                            </div>
                            <div class="form-group">
                                <asp:Label ID="lblPhoneNumber" Text="Số điện thoại:" CssClass="col-sm-2 control-label" runat="server" />
                                <div class="col-sm-10">
                                    <asp:TextBox runat="server" ID="txtPhoneNumber" Text='<%# Bind("PhoneNumber") %>' MaxLength="150"
                                        CssClass="form-control"></asp:TextBox>
                                </div>
                            </div>
                            <div class="form-group">
                                <asp:Label ID="lblAddress" Text="Địa chỉ:" CssClass="col-sm-2 control-label" runat="server" />
                                <div class="col-sm-10">
                                    <asp:TextBox runat="server" ID="txtAddress" Text='<%# Bind("Address") %>' MaxLength="15" TextMode="MultiLine" Rows="3"
                                        CssClass="form-control" HtmlEncode="True"></asp:TextBox>
                                </div>
                            </div>
                            <div class="form-group">
                                <asp:Label ID="lblIsLock" Text="Hiển thị:" CssClass="col-sm-2 control-label" runat="server" />
                                <div class="col-sm-10">
                                    <div class="radio col-sm-1">
                                        <asp:RadioButton ID="rbYes" runat="server" Text="Có" GroupName="rbLock" />
                                    </div>
                                    <div class="radio col-sm-1">
                                        <asp:RadioButton ID="rbNo" runat="server" Text="Không" GroupName="rbLock" />
                                    </div>
                                </div>
                            </div>
                            <asp:Panel ID="pnlIsTop" runat="server" Visible="false">
                                <div class="form-group">
                                    <asp:Label ID="Label1" Text="Học viên tiêu biểu:" CssClass="col-sm-2 control-label" runat="server" />
                                    <div class="col-sm-10">
                                        <div class="radio col-sm-1">
                                            <asp:RadioButton ID="rdbIsTop" runat="server" Text="Có" GroupName="rdbTop" />
                                        </div>
                                        <div class="radio col-sm-1">
                                            <asp:RadioButton ID="rdbNotTop" runat="server" Text="Không" GroupName="rdbTop" />
                                        </div>
                                    </div>
                                </div>
                            </asp:Panel>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <asp:Button ID="btnAdd" runat="server" Text="Thêm mới" CssClass="btnSubmit" OnClick="btnAdd_Click" />
                            <asp:Button ID="btnEdit" runat="server" Text="Cập nhật" CssClass="btnSubmit"
                                OnClick="btnEdit_Click" />
                            <asp:Button ID="btnCancel" runat="server" Text="Hủy" OnClick="btnCancel_Click" />
                        </div>
                        <!-- /.box-footer -->
                    </div>
                </div>
            </div>
        </div>
    </asp:Panel>
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">Danh sách&nbsp;<asp:Label ID="lblUserTitle" runat="server"></asp:Label>:</h3>
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <asp:GridView ID="grvUser" runat="server" AutoGenerateColumns="False"
                        AllowPaging="True" EnableModelValidation="True" CssClass="table table-bordered"
                        AllowSorting="True"
                        OnRowCommand="grvUser_RowCommand" OnRowDeleting="grvUser_RowDeleting"
                        OnRowEditing="grvUser_RowEditing" OnPageIndexChanging="grvUser_PageIndexChanging"
                        PageSize="10">
                        <PagerStyle CssClass="gvpagercss" BackColor="#F6F6F6" ForeColor="Black" HorizontalAlign="Center"
                            VerticalAlign="Middle" />
                        <Columns>
                            <asp:TemplateField ItemStyle-Width="50px" HeaderText="Stt">
                                <ItemTemplate>
                                    <%# Container.DataItemIndex + 1 %>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="UserID" HtmlEncode="false" Visible="false" />
                            <asp:BoundField DataField="UserName" HtmlEncode="false" HeaderText="Tên đăng nhập" ReadOnly="true" />
                            <asp:BoundField DataField="FullName" HtmlEncode="false" HeaderText="Họ và tên" ReadOnly="true"/>
                            <asp:BoundField DataField="Email" HtmlEncode="false" HeaderText="Email" ReadOnly="true" />
                            <asp:BoundField DataField="PhoneNumber" HtmlEncode="false" ItemStyle-Width="150px" HeaderText="Số điện thoại" ReadOnly="true" />
                            <asp:BoundField DataField="JoinDate" ItemStyle-Width="150px" HeaderText="Ngày tham gia" DataFormatString="{0:dd/MM/yyyy}"
                                HtmlEncode="false" ReadOnly="true" />
                            <asp:TemplateField ItemStyle-Width="50px" HeaderText="Tiêu biểu" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <%# Eval("IsTop") == DBNull.Value ? "No" : (bool)Eval("IsTop") == false ? "Không" : "Có" %>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField ItemStyle-Width="30px" HeaderText="Sửa" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:ImageButton ID="imgedit" runat="server" ImageUrl="Images/edit.png" ToolTip="Sửa thông tin"
                                        CommandArgument='<%# Eval("UserID") %>' CommandName="Edit" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField ItemStyle-Width="30px" HeaderText="Xóa" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:ImageButton ID="imgDel" runat="server" ImageUrl="Images/del.gif" ToolTip="Xóa danh mục"
                                        CommandArgument='<%# Eval("UserID") %>' CommandName="Delete" OnClientClick=" return confirm('Bạn có chắc chắn muốn xoá?') " />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                    <div align="left" style="font-weight: bold">
                        <asp:Label ID="lbl_count" runat="server" Visible="false"></asp:Label>
                    </div>
                </div>

                <div class="box-footer clearfix">
                    <div class="col-xs-6 text-left">
                        <i>Bạn đang xem trang
                            <%=grvUser.PageCount==0 &&  grvUser.PageIndex == 0 ? 0 : grvUser.PageIndex+1%>
                            của
                            <%=grvUser.PageCount%></i>
                    </div>
                    <div class="col-xs-6 text-right">
                        <asp:Button ID="btnNew" runat="server" Text="Thêm mới" OnClick="btnNew_Click" />
                    </div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
